TOOL.Category		= "Marcusramse1"
TOOL.Name			= "WebScreen"
TOOL.Command		= nil
TOOL.ConfigName		= ""
CreateClientConVar("webscreen_url", "http://google.se/", false, false)
if ( CLIENT ) then
	language.Add("Tool_webscreen_name", "WebScreen")
	language.Add("Tool_webscreen_desc", "A Website Screen")
	language.Add("Tool_webscreen_0", "Primary: Create WebScreen")
	language.Add("undone_webscreen", "Undone WebScreen")
end
TOOL.ClientConVar["model"] = "models/props/cs_assault/Billboard.mdl"
cleanup.Register("webscreen")
function TOOL:LeftClick( trace )
	if (trace.Entity && trace.Entity:IsPlayer()) then return false end
	if (CLIENT) then return true end
	local ply = self:GetOwner()
	local Ang = trace.HitNormal:Angle()
	local model = self:GetClientInfo("model")
	Ang.pitch = Ang.pitch + 90
	webscreen = MakeWebscreen( ply, trace.HitPos, Ang, model )
	local min = webscreen:OBBMins()
	webscreen:SetPos(trace.HitPos - trace.HitNormal * min.z)
	undo.Create("Webscreen")
		undo.AddEntity(webscreen)
		undo.SetPlayer(ply)
	undo.Finish()
	ply:AddCleanup("webscreen", webscreen)
	return true
end
if (SERVER) then
	function MakeWebscreen( ply, Pos, Ang, model )
		if(!ply:IsAdmin()) then return end
		local webscreen = ents.Create("gmod_webscreen")
		webscreen:SetModel(model)
		webscreen:SetAngles(Ang)
		webscreen:SetPos(Pos)
		webscreen:Spawn()
		webscreen:Activate()
		SpawnGuy=ply
		return webscreen
	end
	duplicator.RegisterEntityClass("gmod_webscreen", MakeWebscreen, "Pos", "Ang", "Model")
end
function TOOL.BuildCPanel(panel)
	panel:AddControl("Header", { Text = "#Tool_webscreen_name", Description = "#Tool_webscreen_desc" })
	panel:AddControl("TextBox", {Label = "URL: ",MaxLength = 255,Text = "http://google.com/",Command = "webscreen_url",})
end
	
